package com.principles.create.builder;



/**
 * @Description  生成器模式
 * @Date 2025/1/29 23:57
 **/
public class BuilderPattern {
    public static void main(String[] args) {
        House build = new House.Builder().setDoor(new Door()).setWall(new Wall()).setWindow(new Window()).build();


    }
}


class House{
    private Window window;
    private Door door;
    private Wall wall;

    public static final class Builder {
        private Window window;
        private Door door;
        private Wall wall;

        public Builder() {
        }

        public static Builder aTest() {
            return new Builder();
        }

        public Builder setWindow(Window window) {
            this.window = window;
            return this;
        }

        public Builder setDoor(Door door) {
            this.door = door;
            return this;
        }

        public Builder setWall(Wall wall) {
            this.wall = wall;
            return this;
        }

        public House build() {
            House test = new House();
            test.door = this.door;
            test.wall = this.wall;
            test.window = this.window;
            return test;
        }
    }
}

class Window{}
class Door{}
class Wall{}